package com.oolatina;

import android.content.Context;
import android.graphics.Color;
import android.view.Display;
import android.view.Gravity;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SCLabel 
{
	int _width;
	int _height;
	int _x;
	int _y;
	Context _context;
	int ScreenWidth;
	int ScreenHeight;
	TextView texte;
	
	public void init(LinearLayout layout, Context thisContext)
    {
		 _width = 0;
		 _height = 0;
		 _x = 0;
		 _y = 0;
		 _context = thisContext;
		 
		 WindowManager wm = (WindowManager) thisContext.getSystemService(Context.WINDOW_SERVICE);
	     Display display = wm.getDefaultDisplay();
	     ScreenWidth = display.getWidth();
	     ScreenHeight = display.getHeight();
		 
	     LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ScreenWidth, 60);
	     layoutParams.setMargins(0,0,0,0);
	     
	     texte = new TextView(thisContext);
	     texte.setText("");
	     texte.setLayoutParams(layoutParams);
	     texte.setTextColor(Color.argb(255,255,255,255));
	     texte.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
	     layout.addView(texte);
    }
	
	public void SetPosition(int x,int y)
	{
		_x = x;
		_y = y;
		
		FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
				_width,_height);
        layoutParams.setMargins(_x,_y,0,0);
        texte.setLayoutParams(layoutParams);
	}
	
	public void SetSize(int width,int height)
	{
		_width = width;
		_height = height;
		
		FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
				_width,_height);
        layoutParams.setMargins(_x,_y,0,0);
        texte.setLayoutParams(layoutParams);
	}
	
	public void SetPourcentSize(int width, int height)
	{
		float radioWidth = (float)ScreenWidth/100;
    	float radioHeight = (float)ScreenHeight/100;
    	_width = (int)(radioWidth*width);
    	_height = (int)(radioHeight*height);
		
		FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
				_width,_height);
        layoutParams.setMargins(_x,_y,0,0);
        texte.setLayoutParams(layoutParams);
	}
	
	public int SetPourcentWidth(int width)
	{
		float radioWidth = (float)ScreenWidth/100;
		_width = (int)(radioWidth*width);
		LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
				_width,_height);
//        layoutParams.setMargins(_x,_y,0,0);
        texte.setLayoutParams(layoutParams);
        return _width;
	}
	
	public int SetPourcentHeight(int height)
	{
		float radioHeight = (float)ScreenHeight/100;
		_height = (int)(radioHeight*height);
		LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
				_width,_height);
//        layoutParams.setMargins(_x,_y,0,0);
        texte.setLayoutParams(layoutParams);
        return _height;
	}
	
	public void SetBackgroundColor(int alpha,int red,int green,int blue)
    {
		texte.setBackgroundColor(Color.argb(alpha,red,green,blue));
    }
	
	public void SetTitleColor(int alpha,int red,int green,int blue)
    {
        texte.setTextColor(Color.argb(alpha,red,green,blue));
    }

    public void SetTitleFontSize(int size)
    {
        texte.setTextSize(size);
    }

    public void SetTitle(String title)
    {
        texte.setText(title);
    }
}
